package edu.java.lectures.lec05.polimorphism;

/**
 * Rawnostranen triygylnik
 * 
 * @author admin
 */
public class EquilateralTriangle extends Object { // hidden extend by java

    // --- Static Block ------------------------------------------------------
    static {
	System.out.println("static block 1 - EquilateralTriangle");
    }
    
    static {
	System.out.println("static block 2 - EquilateralTriangle");
    }

    // --- Dynamic Block ------------------------------------------------------
    {
	System.out.println("dynamic block 1 - EquilateralTriangle");
    }

    {
	System.out.println("dynamic block 2 - EquilateralTriangle");
    }
    // --- Instance Variable ---------------------------------------------------

    static double statA=22;
    double a;

    // --- Constructors --------------------------------------------------------

    public EquilateralTriangle() {
	// first thing which is invoked on the FIRST LINE of the constructor is:
	// super(...) / this(...)
	super();
	a=100;
	System.out.println("Constructor EquilateralTriangle");
    }

    public EquilateralTriangle(double a) {
	this.a = a;
    }

    // --- Getters and Setters -------------------------------------------------

    public double getA() {
	return a;
    }

    public void setA(double a) {
	this.a = a;
    }

    // --- Method --------------------------------------------------------------

    public double calculatePerimeter() {
	return 3 * a;
    }

    public double calculateSurface() {
	return ((Math.sqrt(3) / 2) * Math.pow(a, 2)) / 2;
    }

    @Override
    public String toString() {
	return "(" + this.a + ")";
    }

    public String getMedicenterName() {
	return "E";
    }
}
